LSEEK
Section: System Calls (2)
Index
Return to Main Contents
BSD mandoc
BSD 4
NAME
lseek
- reposition read/write file offset
SYNOPSIS
Fd #include <unistd.h>
Ft off_t
Fn lseek int fildes off_t offset int whence
DESCRIPTION
The
Fn lseek
function repositions the offset of the file descriptor
Fa fildes
to the
argument
Fa offset
according to the directive
Fa whence.
The argument
Fa fildes
must be an open
file descriptor.
Fn Lseek
repositions the file pointer
Fa fildes
as follows:
- If
-
Fa whence
is
SEEK_SET
the offset is set to
Fa offset
bytes.
- If
-
Fa whence
is
SEEK_CUR
the offset is set to its current location plus
Fa offset
bytes.
- If
-
Fa whence
is
SEEK_END
the offset is set to the size of the
file plus
Fa offset
bytes.
The
Fn lseek
function allows the file offset to be set beyond the end
of the existing end-of-file of the file. If data is later written
at this point, subsequent reads of the data in the gap return
bytes of zeros (until data is actually written into the gap).
Some devices are incapable of seeking. The value of the pointer
associated with such a device is undefined.
RETURN VALUES
Upon successful completion,
Fn lseek
returns the resulting offset location as measured in bytes from the
beginning of the file.
Otherwise,
a value of -1 is returned and
errno
is set to indicate
the error.
ERRORS
Fn Lseek
will fail and the file pointer will remain unchanged if:
- Bq Er EBADF
-
Fildes
is not an open file descriptor.
- Bq Er ESPIPE
-
Fildes
is associated with a pipe, socket, or FIFO.
- Bq Er EINVAL
-
Fa Whence
is not a proper value.
SEE ALSO
dup(2),
open(2)
BUGS
This document's use of
Fa whence
is incorrect English, but is maintained for historical reasons.
STANDARDS
The
Fn lseek
function conforms to
St -p1003.1-88 .
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUES
-
- ERRORS
-
- SEE ALSO
-
- BUGS
-
- STANDARDS
-
This document was created by
man2html,
using the manual pages.
Time: 19:41:54 GMT, December 25, 2022